package com.javabi.htmlbuilder.html.element.content;

import com.javabi.htmlbuilder.html.HTMLBuilder;
import com.javabi.htmlbuilder.html.HTMLContent;

/**
 * A HTML Text Content.
 */
public class Text implements HTMLContent {

	/** The text. */
	private String text = null;

	/**
	 * Creates a new text.
	 */
	public Text() {
	}

	/**
	 * Creates a new text.
	 * @param text the text.
	 */
	public Text(String text) {
		this.text = text;
	}

	/**
	 * Returns the text
	 * @return the text
	 */
	public String getText() {
		return text;
	}

	/**
	 * Sets the text
	 * @param text the text to set
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * Returns true to format this element.
	 * @return true to format this element.
	 */
	public boolean format() {
		return text.indexOf('\n') != -1;
	}

	/**
	 * Append this to the given html builder.
	 * @param html the html builder.
	 * @return the html builder.
	 */
	public HTMLBuilder appendTo(HTMLBuilder html) {
		html.content(text);
		return html;
	}

}
